package com.shareach.domain;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;
import com.shareach.util.Globals;

/**
 * 团购基础数据
 * 
 * @author zuoshuaiok@gmail.com
 * 
 *         2013-1-28
 */
@Document(collection = "bizTuan")
public class BizTuanDomain extends Entity {
	// /标题
	private String title;
	// 团购商家数
	private Integer shopCount;
	// 描述
	private String descry;
	// 截止时间
	private Date end;
	// 图片
	private String img;
	// 城市
	private Long city;
	// 参见 来源网站 BaseSite site+siteId作为唯一标识
	private String site;// 来源网站

	private String siteId;// 来源网站id

	// 折扣
	private Integer discount;
	// /现价
	private Double price;
	// 原价
	private Double orgPrice;
	// 状态
	private Integer status;
	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;

	public Long getCity() {
		return city;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public String getDescry() {
		return descry;
	}

	public Integer getDiscount() {
		return discount;
	}

	public Date getEnd() {
		return end;
	}

	public String getImg() {
		return img;
	}

	public Double getOrgPrice() {
		return orgPrice;
	}

	public Double getPrice() {
		return price;
	}

	public Integer getShopCount() {
		return shopCount;
	}

	public String getSite() {
		return site;
	}

	public String getSiteId() {
		return siteId;
	}

	public Integer getStatus() {
		return status;
	}

	public String getTitle() {
		return title;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public void setDescry(String descry) {
		this.descry = descry;
	}

	public void setDiscount(Integer discount) {
		this.discount = discount;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public void setOrgPrice(Double orgPrice) {
		this.orgPrice = orgPrice;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public void setShopCount(Integer shopCount) {
		this.shopCount = shopCount;
	}

	public void setSite(String site) {
		this.site = site;
	}

	public void setSiteId(String siteId) {
		this.siteId = siteId;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public BizTuanDomain compareTo(BizTuanDomain domain) {
		BizTuanDomain change = new BizTuanDomain();
		if (domain == null) {
			return change;
		}

		if (StringUtils.isNotEmpty(domain.getTitle())) {
			if (this.title == null || !this.title.trim().equals(domain.getTitle().trim())) {
				change.setTitle(domain.getTitle().trim());
			}
		}
		if (StringUtils.isNotEmpty(domain.getImg())) {
			if (this.img == null || !this.img.trim().equals(domain.getImg().trim())) {
				change.setImg(domain.getImg().trim());
			}
		}
		if (StringUtils.isNotEmpty(domain.getDescry())) {
			if (this.descry == null || !this.descry.trim().equals(domain.getDescry().trim())) {
				change.setDescry(domain.getDescry().trim());
			}
		}
		if (domain.getEnd() != null) {
			if (this.end != null) {
				if (!Globals.FORMAT_TYPE_A.format(this.end).equals(Globals.FORMAT_TYPE_A.format(domain.getEnd()))) {
					change.setEnd(domain.getEnd());
				}
			} else {
				change.setEnd(domain.getEnd());
			}
		}
		if (domain.getShopCount() != null) {
			if (null == this.shopCount || !this.shopCount.equals(domain.getShopCount())) {
				change.setShopCount(domain.getShopCount());
			}
		}
		if (domain.getCity() != null) {
			if (null == this.city || !domain.getCity().equals(this.city)) {
				change.setCity(domain.getCity());
			}
		}
		if (domain.getDiscount() != null) {
			if (null == domain.discount || !domain.discount.equals(this.discount)) {
				change.setDiscount(domain.getDiscount());
			}
		}
		if (domain.getPrice() != null) {
			if (this.price == null || !domain.getPrice().equals(this.price)) {
				change.setPrice(domain.getPrice());
			}
		}
		if (domain.getOrgPrice() != null) {
			if (this.orgPrice == null || !domain.getOrgPrice().equals(this.orgPrice)) {
				change.setOrgPrice(domain.getOrgPrice());
			}
		}
		if (domain.getStatus() != null) {
			if (this.status == null || !domain.getStatus().equals(this.status)) {
				change.setStatus(domain.getStatus());
			}
		}
		return change;
	}
}
